﻿@model DMS.BO.Models.CityHomeViewModel
@{
    ViewBag.Title = "City Management";
}

<link rel="stylesheet" href="http://jqueryvalidation.org/files/demo/site-demos.css">

<h2>Single City</h2>
@using (Html.BeginForm("Index", "City", new { ReturnUrl = "" }, FormMethod.Post, new { @class = "form-horizontal",@id="frmCity" }))
{
     @Html.AntiForgeryToken()
    <div class="form-group">        
        @Html.LabelFor(m => m.cityID, new { @class = "col-md-2 control-label" })
        <div class="col-md-2">
            @Html.TextBoxFor(m => m.cityID, new { @class = "form-control" })
            @Html.ValidationMessageFor(m => m.cityID)

            <label for="field">Required: </label>
             <input type="text" name="nameVal" id="nameVal" value="" style="width: 250px">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-2">
            <input type="submit" value="Tim kiem" class="btn btn-default" />
        </div>
    </div>
}
<p>
    City Name:
</p>
<p>
    <b>
        @Model.cityResult.Name
    </b>
</p>
<p>
    City Code:
</p>
<p>
    <b>
        @Model.cityResult.Code
    </b>
</p>
<hr />
<h2>All City</h2>
<p>
    <table border="1">
        <tr>
            <td style="font-weight: bold">ID
            </td>
            <td style="font-weight: bold">Name
            </td>
        </tr>
        @foreach (var city in Model.lstCity)
        {
            <tr>
                <td>
                    @city.ID.ToString()
                </td>
                <td>
                    @city.Name
                </td>
            </tr>
        }
    </table>
</p>
<script>

    jQuery.validator.setDefaults({
        debug: true,
        success: "valid"
    });
    $("#frmCity").validate({
        rules: {
            nameVal: {
                required: true
            }
        }
    });
   
</script>

